package com.epoint.mybatispluslearning.configuration;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;
import java.sql.SQLException;

@Configuration
public class DataSourceConfiguration {

    /**
     * 将整个项目的数据源替换成druid的
     */
    @Bean
    @ConfigurationProperties("spring.datasource") // 这个注解 也可以写在方法上，会把 返回值和 配置文件里的属性绑定
    public DataSource druidDataSource() throws SQLException {
        return new DruidDataSource();
    }

}
